home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_objc.idb / usr / freeware / bin / .objc.egcs.z / .objc.egcs
Encoding:
Text File  |  1999-07-16  |  19.2 KB  |  616 lines

  1. #! /bin/sh
  2. # Portable Object Compiler (c) 1997,98.  All Rights Reserved.
  3. # Driver Script (objc-2.3.8)
  4. #
  5. # $Id: objc.in,v 1.3 1999/06/23 19:23:28 stes Exp $
  6. #
  7. # DO NOT EDIT -- configure objc-2.3.8 mips-sgi-irix6.2
  8.  
  9. #
  10. # OBJCOPT can be set, as an environment variable, to a list
  11. # of options that is always prepended to command line
  12. # arguments of "objc".
  13. #
  14.  
  15. if [ "$CC" = "`basename $0`" ]; then
  16.   cc="egcs";
  17. else
  18.   cc=${CC-"egcs"}
  19. fi
  20.  
  21. set - $OBJCOPT "$@"
  22.  
  23. #
  24. # OBJCDIR is the top directory of the distribution.
  25. # Can be set as an environment variable (or with -B)
  26. #
  27.  
  28. objcdir=${OBJCDIR-${ROOT}/usr/freeware}
  29. gcprefix=${ROOT}/usr/freeware
  30.  
  31. ld=${LD-"ld"}
  32. cxx=${CCPLUS-"c++"}
  33. cpp=${CPP-"egcs -E"}
  34. cppwantsdotc=0
  35. cxxpp="$cxx -E"
  36. cpargs="-D__PORTABLE_OBJC__ "
  37. ocargs="-gnu"
  38. ccargs=""
  39. ldargs=""
  40. dlargs="-shared"
  41. dlfile="objcdlso.ld"
  42. plldargs=""
  43. dlxccargs=""
  44. dlxldargs=""
  45. picflag="-fpic"
  46. staticflag="-static"
  47. ccdollarflag="-fdollars-in-identifiers"
  48. cppimportflag="-x objective-c -Wno-import"
  49. picocargs=""
  50. linkformat="unix"
  51. nm="nm"
  52. ii="cc"
  53.  
  54. inputs=""
  55. extensions=""
  56. actions=""
  57. output="a.out"
  58. t="${TMPDIR+${TMPDIR}/}"
  59.  
  60. comments=n
  61. precompile=y
  62. compile=y
  63. link=y
  64. linkdl=n
  65. include=y
  66. libs=""
  67. finlibs=""
  68. uselibs=y
  69. blocks=1
  70. ppi=0
  71. verbose=n
  72. debug=n
  73. dynamic=n
  74. retain=n
  75. stopflag="-c"
  76. retaincpp=n
  77. profile=n
  78. xstr=xstr
  79. runxstr=n
  80. useoutput=n
  81. cplusplus=n
  82. postlink=0
  83. initcall=_objcInit
  84. pager=${MANPAGER-more}
  85. objcrt=objcrt
  86. objpak=objpak
  87. cakit=cakit
  88.  
  89. # by default .c files compile as C, not as Objective C
  90. actionc="c"
  91. actioncc="cc"
  92.  
  93. # how to deal with shared libs (use -l or not)
  94. uselflag=1
  95. sosuffix=".so"
  96.  
  97. vermsg="Portable Object Compiler - objc-2.3.8 - mips-sgi-irix6.2"
  98. cpymsg="Distributed under the terms of the GNU LGPL."
  99.  
  100. case $# in
  101. 0) $pager "$objcdir/lib32/objchelp.txt"; exit 0;;
  102. esac
  103.  
  104. while :
  105. do
  106.  
  107.   case $# in
  108.     0)  break ;;
  109.   esac
  110.  
  111.   arg="$1" ;
  112.   case $arg in
  113.     @*)              optfile=`expr $arg : '@\(.*\)'`; shift;
  114.                      if [ -f $optfile ]; then
  115.              set - `cat $optfile` $*;
  116.                  else
  117.              echo "objc: can't find $optfile";exit 1;
  118.              fi
  119.              ;;
  120.     -c|-Fo)          link=n ;;
  121.     -O)              ccargs="$ccargs $arg" ;;
  122.     -C|-Fi|-Fii)     comments=y ; link=n ; compile=n ; retain=y ;;
  123.     -dl)             linkdl=y;postlink=y;;
  124.     -prod)           ccargs="$ccargs -prod";;
  125.     -dynamic|-dlx)   ocargs="$ocargs -noShared";
  126.                  ccargs="$ccargs $dlxccargs";
  127.                  ldargs="$ldargs $dlxldargs";
  128.                      initcall="_objcInitNoShared";
  129.              dynamic=y;
  130.              ;;
  131.     -dump)           link=n ; compile=n ; # simply output objc - for debugging
  132.                      retain=y ; ocargs="$ocargs -objc" ;;
  133.     -export)         ocargs="$ocargs $arg";shift;ocargs="$ocargs $1";;
  134.     -dllexport)      ocargs="$ocargs $arg";;
  135.     -ObjC|-objc)     actionc="m";actioncc="mm" ;;
  136.     -ObjCpp|-import) cpargs="$cpargs $cppimportflag";; 
  137.     -cplus)             cplusplus=y;postlink=1;;
  138.     -dollars)        ccargs="$ccargs $ccdollarflag";;
  139.     -E)              link=n;precompile=n;;
  140.     -i)              stopflag="-i";link=n;; # tcc
  141.     -Fj)             stopflag="-i";link=n;; # tcc
  142.     -N)              cpargs="$cpargs $arg" ;;
  143.     -nostdinc)         cpargs="$cpargs $arg" ;; # for GNU cpp
  144.     -noobjcinc|-noI) include=n ;; # -noI for compatibility with Stepstone
  145.     -noLibs)         uselibs=n ;; # for cross compiles of runtime
  146.     -noBlocks)         blocks=0 ;;
  147.     -m486)           ccargs="$ccargs $arg";;
  148.     -nno-486)        ccargs="$ccargs $arg";;
  149.     -noFiler)         ocargs="$ocargs $arg" ;;
  150.     -fwd)         ocargs="$ocargs $arg" ;;
  151.     -noFwd)         ocargs="$ocargs $arg" ;;
  152.     -noCategories)   ocargs="$ocargs $arg" ;;
  153.     -noSelfAssign)   ocargs="$ocargs $arg" ;;
  154.     -noNilRcvr)         ocargs="$ocargs $arg" ;;
  155.     -noCache)        ocargs="$ocargs $arg" ;;
  156.     -st80)         ocargs="$ocargs $arg";;
  157.     -debugInfo)      ocargs="$ocargs $arg" ;;
  158.     -g)              ccargs="$ccargs $arg" ;
  159.                      debug=y ;; # could be used to link against debug libs
  160.     -o)              output="$2";useoutput=y; # used for cc -c foo.m -o bar.o
  161.                      shift ;;
  162.     -pg|-ql|-qf)     ccargs="$ccargs $arg" ; # gprof, SCO lprof, fprof
  163.              ldargs="$ldargs $arg";
  164.              profile=y;; # could be used to link against prof libs
  165.     -q|-quiet)       ocargs="$ocargs -quiet" ;;
  166.     -u|-unbuf)       ocargs="$ocargs -u" ;;
  167.     -help|--help)    $pager "$objcdir/lib32/objchelp.txt"; exit 0;;
  168.     -usage|--usage)  $pager "$objcdir/lib32/objchelp.txt"; exit 0;;
  169.     -undef)         cpargs="$cpargs $arg" ;
  170.              ccargs="$ccargs $arg" ;;    # for .c input
  171.     -static)         libs="$libs $staticflag";; # like -Wl,-a,archive
  172.     -pic)            ccargs="$ccargs $picflag"; # like +z or -fpic
  173.                      ocargs="$ocargs $picocargs -noShared"; # like -dllexport
  174. # trick: don't define _objcInit; means that user will have to use -dynamic
  175.                      cpargs="$cpargs -DOBJCRT_NOSHARED";; 
  176.     -fpic)           ccargs="$ccargs $arg";;
  177.     +z|+Z)           ccargs="$ccargs $arg";; # HP-UX PIC 
  178.     -version|--version) echo $vermsg;echo $cpymsg;exit 0 ;;
  179.     -init)           shift ; initcall="$1" ;;
  180.     -main)           shift ; ocargs="$ocargs $arg $1" ;;
  181.     -builtintype)    shift ; ocargs="$ocargs -builtintype $1" ;;
  182.     -msdos)          ocargs="$ocargs $arg";;
  183.     -builtinType)    shift ; ocargs="$ocargs -builtintype $1" ;;
  184.     -builtinfunction) shift ; ocargs="$ocargs -builtinfunction $1" ;;
  185.     -builtinFunction) shift ; ocargs="$ocargs -builtinfunction $1" ;;
  186.     -ppi)            ocargs="$ocargs -ppi -oneperfile -noFwd -noBlocks";
  187.                      ccargs="$ccargs $ccdollarflag"; # dont assume egcs
  188.                      cpargs="$cpargs $cppimportflag"; # dont assume gnu cpp
  189.              ppi=1;
  190.              ;;
  191.     -retain)         retain=y ; retaincpp=y ;;
  192.     -retaincpp)      retaincpp=y ;;
  193.     -xstr)           runxstr=y; shift; xstrdb="$1" ;;
  194.     -noSelTbl)         ocargs="$ocargs $arg" ;;
  195.     -inlinecache|-inlineCache)    ocargs="$ocargs -inlinecache";;
  196.     -opt)            shift;ccargs="$ccargs -opt $1";; # mwc
  197.     -sym)            shift;ccargs="$ccargs -sym $1";; # mwc
  198.     -xm)             shift;ccargs="$ccargs -xm $1";; # mwc
  199.     -oneperfile)     ocargs="$ocargs $arg";;
  200.     -cthreads)       objcrt=objcrtth;; 
  201.     -pthreads)       objcrt=objcrtth;finlibs="$finlibs -lpthread";;
  202.     -otb)            cpargs="$cpargs -DOTBCRT=1";
  203.                      ocargs="$ocargs $arg";
  204.              objcrt=otbcrt;objpak=otbpak;cakit=cakitb;
  205.              ;;
  206.     -gc | -boehm)    objcrt=objcrtgc;
  207.                      cpargs="$cpargs -I$gcprefix/include";
  208.              finlibs="$finlibs $gcprefix/lib32/gc.a";
  209.              ;;
  210.     -refcnt)         cpargs="$cpargs -DOBJC_REFCNT=1";
  211.                      ocargs="$ocargs $arg";
  212.                      objcrt=objcrtr;objpak=objpakr;cakit=cakitr;;
  213.     -postlink|-postLink) postlink=1;;
  214.     -noPostlink|-noPostLink) postlink=0;;
  215.     -nolinetags|-noTags) ocargs="$ocargs -nolinetags";;
  216.     -shortTags) ocargs="$ocargs $arg";;
  217.     -objc1trace)     ocargs="$ocargs -trace";;
  218.     -v|-verbose)     verbose=y ;; # -verbose has a meaning for DEC cc !
  219.     -w)              ocargs="$ocargs -w" ;;
  220.     -WLex)           ocargs="$ocargs $arg" ;;
  221.     -WFwd)           ocargs="$ocargs $arg" ;;
  222.     -cpOpt:*)        cpargs="$cpargs `expr $arg : '-cpOpt:\(.*\)'`" ;;
  223.     -cppOpt:*)       cpargs="$cpargs `expr $arg : '-cppOpt:\(.*\)'`" ;;
  224.     -Wp,*)           cpargs="$cpargs `expr $arg : '-Wp,\(.*\)'`" ;;
  225.     -Wp:*)           cpargs="$cpargs `expr $arg : '-Wp:\(.*\)'`" ;;
  226.     -ocOpt:*)        ocargs="$ocargs `expr $arg : '-ocOpt:\(.*\)'`" ;;
  227.     -objc1Opt:*)     ocargs="$ocargs `expr $arg : '-objc1Opt:\(.*\)'`" ;;
  228.     -Wo,*)           ocargs="$ocargs `expr $arg : '-Wo,\(.*\)'`" ;;
  229.     -Wo:*)           ocargs="$ocargs `expr $arg : '-Wo:\(.*\)'`" ;;
  230.     -ccOpt:*)        ccargs="$ccargs `expr $arg : '-ccOpt:\(.*\)'`" ;;
  231.     -Wc,*)           ccargs="$ccargs `expr $arg : '-Wc,\(.*\)'`" ;;
  232.     -Wc:*)           ccargs="$ccargs `expr $arg : '-Wc:\(.*\)'`" ;;
  233.     -ldOpt:*)        ldargs="$ldargs `expr $arg : '-ldOpt:\(.*\)'`" ;;
  234.     -Wl,*)           ldargs="$ldargs `expr $arg : '-Wl,\(.*\)'`" ;;
  235.     -Wl:*)           ldargs="$ldargs `expr $arg : '-Wl:\(.*\)'`" ;;
  236.     -Wall)           ccargs="$ccargs $arg" ;; # GNU cc
  237.     -Wno-import)     ccargs="$ccargs $arg" ;; # GNU cc
  238.     -Werror)         ccargs="$ccargs $arg" ;; # GNU cc
  239.     -Wno-sign-compare) ccargs="$ccargs $arg" ;; # GNU cc
  240.     -fno-strength-reduce) ccargs="$ccargs $arg" ;; # GNU cc
  241.     -64)             ccargs="$ccargs $arg";ldargs="$ldargs $arg";; # SGI
  242.     -32)             ccargs="$ccargs $arg";ldargs="$ldargs $arg";; # SGI
  243.     -n32)            ccargs="$ccargs $arg";ldargs="$ldargs $arg";; # SGI
  244.     -mips[1-9])      ccargs="$ccargs $arg" ldargs="$ldargs $arg";; # SGI
  245.     -noobject)       ccargs="$ccargs $arg" ;; # DEC cc
  246.     -edit[0-9])      ccargs="$ccargs $arg" ;; # DEC cc
  247.     -w[0-9])         ccargs="$ccargs $arg" ;; # DEC cc
  248.     -migrate)        ccargs="$ccargs $arg" ;; # DEC cc
  249.     -assume)         ccargs="$ccargs $1 $2"; shift;;  # DEC cc
  250.     -rpath)          ldargs="$ldargs $1 $2"; shift;;  # SGI ld rpath
  251.     -xansi)          ccargs="$ccargs $arg" ;; # SGI cc -xansi
  252.     -all)            ldargs="$ldargs $arg";;  # SGI ld shlib
  253.     -no_unresolved)  ldargs="$ldargs $arg";;  # SGI ld shlib
  254.     *.h)             inputs="$inputs $arg" ;
  255.                      extensions="$extensions h" ;
  256.                      actions="$actions m" ;;
  257.     *.m)             inputs="$inputs $arg" ;
  258.                      extensions="$extensions m" ;
  259.                      actions="$actions m" ;;
  260.     *.mm)            inputs="$inputs $arg" ; cplusplus=y;postlink=1 ;
  261.                      extensions="$extensions mm" ;
  262.                      actions="$actions mm" ;;
  263.     *.i)             inputs="$inputs $arg" ;
  264.                      extensions="$extensions i" ;
  265.                      actions="$actions $actionc" ;;
  266.     *.c)             inputs="$inputs $arg" ;
  267.                      extensions="$extensions c" ;
  268.              # .c files can compile as 'm' using -ObjC
  269.                      actions="$actions $actionc" ;;
  270.     *.cc)            inputs="$inputs $arg" ; cplusplus=y ;postlink=1;
  271.                      extensions="$extensions cc" ;
  272.                      actions="$actions $actioncc" ;;
  273.     *.cpp)           inputs="$inputs $arg" ; cplusplus=y ;postlink=1;
  274.                      extensions="$extensions cpp" ;
  275.                      actions="$actions $actioncc" ;;
  276.     *.cxx)           inputs="$inputs $arg" ; cplusplus=y ;postlink=1;
  277.                      extensions="$extensions cxx" ;
  278.                      actions="$actions $actioncc" ;;
  279.     *.C)             inputs="$inputs $arg" ; cplusplus=y ;postlink=1;
  280.                      extensions="$extensions C" ;
  281.                      actions="$actions $actioncc" ;;
  282.     *.s)             inputs="$inputs $arg" ;
  283.                      extensions="$extensions s" ;
  284.                      actions="$actions s" ;;
  285.     *.o)             inputs="$inputs $arg" ;
  286.                      extensions="$extensions o" ;
  287.                      actions="$actions o" ;;
  288.     *.j)             inputs="$inputs $arg" ;
  289.                      extensions="$extensions j" ;
  290.                      actions="$actions c" ;;
  291.     *.a)             libs="$libs $arg";;
  292.     *.ta)            libs="$libs $arg";;
  293.     *.so*)           libs="$libs $arg";;
  294.     -Wf,*)           ccargs="$ccargs $arg" ;;    # SGI cc -Wf,-XNh2000
  295.     -A*)             ccargs="$ccargs $arg" ;;    # HP-UX -Aa, -Ae etc.
  296.     -D*)             cpargs="$cpargs $arg" ;
  297.                      ccargs="$ccargs $arg" ;;    # for .c input
  298.     -U*)             cpargs="$cpargs $arg" ;
  299.                      ccargs="$ccargs $arg" ;;    # for .c input
  300.     -B*)         objcdir=`expr $arg : '-B\(.*\)'`;;
  301.     -T*)         t=`expr $arg : '-T\(.*\)'`;;
  302.     -I*)             cpargs="$cpargs $arg" ;;
  303.     -L*)             libs="$libs $arg" ;;
  304.     -l*)             libs="$libs $arg" ;;
  305.     -J*)             libs="$libs $arg" ;;
  306.     -j*)             libs="$libs $arg" ;;
  307.     -O*)         ccargs="$ccargs $arg" ;;
  308.     -g*)         ccargs="$ccargs $arg" ;;
  309.     -w*)             ocargs="$ocargs $arg" ;; # -wClassUsedAsType etc
  310.     -Y*)         ccargs="$ccargs $arg";; # tcc
  311.     -*)              ccargs="$ccargs $arg";;
  312.     *)               echo "objc: Illegal file type " $arg ;exit 1;;
  313.   esac
  314.  
  315.   shift
  316. done
  317.  
  318. #
  319. # don't depend on $PATH for finding objc1
  320. # for cross compiles this is not what we want
  321. #
  322.  
  323. bindir="$objcdir/bin"
  324. libdir="$objcdir/lib32"
  325. hdrdir="$objcdir/include"
  326. objc1=$bindir/objc1
  327. objcplus1=$bindir/objc1
  328.  
  329. case $verbose in
  330.   y)  set -x ;;
  331. esac
  332.  
  333. objfiles=""
  334. if [ $cplusplus = y ]; then ocargs="$ocargs -noFwd -cplus "; fi
  335. if [ $postlink = 1 ]; then 
  336.     ocargs="$ocargs -postlink "; 
  337.     ldargs="$ldargs $plldargs";
  338. fi
  339. ocargs="$ocargs -init $initcall"
  340.  
  341. case $include in
  342.   # for cross compiles we compile with -noI to use the target config.h
  343.   y) cpargs="$cpargs -I$hdrdir/objcrt -I$hdrdir/objpak -I$hdrdir/cakit";;
  344. esac
  345.  
  346. case $ppi in
  347.   1) cpargs="$cpargs -I$hdrdir/ppi";;
  348. esac
  349.  
  350. case $blocks in
  351.   1) cpargs="$cpargs -DOBJC_BLOCKS=1";;
  352.   0) cpargs="$cpargs -DOBJC_BLOCKS=0";ocargs="$ocargs -noBlocks";;
  353. esac
  354.  
  355. rmf()
  356. {
  357.   # or IRIX, rm -f seems to complain when invoked with no args 
  358.   if [ -n "$*" ]; then rm -f $*; fi
  359. }
  360.  
  361. exits()
  362. {
  363.    status="$1"
  364.    shift;rmf $*
  365.    exit $status
  366. }
  367.  
  368. case $cplusplus in
  369.     y) thecc="$cxx";thecpp="$cxxpp";occ1="$objcplus1";;
  370.     *) thecc="$cc";thecpp="$cpp";occ1="$objc1";;
  371. esac
  372.  
  373. for input in $inputs
  374.  do
  375.     set $extensions;extension="$1";shift;extensions="$*"
  376.     set $actions;action="$1";shift;actions="$*"
  377.  
  378.     if [ ! -f $input ]; then echo "objc: can't open $input"; continue; fi
  379.     base=`basename $input .$extension`
  380.  
  381.     # we have to be careful with -o
  382.     # there might be a length limitation on the
  383.     # filename for -o, which comes from the limit imposed
  384.     # by the underlying cc (e.g. on AIX cc not so big)
  385.     
  386.     useoflag="n"
  387.     ofile="$base.o"
  388.     # like in cc -c foo.m -o bar.o
  389.     if [ $useoutput = y -a $link = n ]; then useoflag="y";ofile="$output"; fi;
  390.  
  391.     case $action in
  392.       m|mm)
  393.         junk="";
  394.     
  395.     tmpp="$t$base.P"
  396.  
  397.         # we can't place the .c file in the $t directory
  398.     # on platforms like Digital UNIX (cc -E /tmp/foo.c)
  399.     # because this changes the include path
  400.  
  401.     case $cplusplus in
  402.         n) tmpi="$t$base.i";tmpc="$base.c";;
  403.         # .ii doesn't work with cfront, but does for egcs
  404.         y) tmpi="$t$base.$ii";tmpc="$base.cc";;
  405.     esac
  406.     
  407.     if [ $retain = n ]; then junk="$junk $tmpi"; fi
  408.     if [ $retaincpp = n ]; then junk="$junk $tmpp"; fi
  409.     trap 'exits 1 $junk' 1 2 3 10 15
  410.     rmf $junk
  411.  
  412.     # instead of invoking /lib/cpp, we prefer the cc -E
  413.     # interface because the location of cpp is not standard
  414.     # across different machines.
  415.  
  416.     # note however that at least the SGI cc -E interprets
  417.     # a .m suffix as "FORTRAN".
  418.     
  419.     case $extension in
  420.       h|c|cc) tmpc="$input" ;;
  421.       m) if [ $cppwantsdotc = 1 ]; then
  422.            echo '#line 1 "'$input'"' > $tmpc 
  423.            cat $input >> $tmpc ; junk="$junk $tmpc" 
  424.          else
  425.            tmpc="$input"; # .m files are okay for egcs
  426.          fi
  427.          ;;
  428.       *) echo '#line 1 "'$input'"' > $tmpc ;
  429.          cat $input >> $tmpc ; junk="$junk $tmpc" ;;
  430.     esac
  431.  
  432.         if [ $precompile = y ]; then
  433.        if $thecpp $ccargs $cpargs $tmpc >$tmpp; then
  434.               if $occ1 $ocargs -filename $input $tmpp $tmpi; then
  435.                 if [ $runxstr = y ]; then
  436.                     junk="$junk x.c";
  437.                     $xstr -c -s $xstrdb $tmpi;mv x.c $tmpi
  438.                 fi
  439.                 if [ $compile = y ]; then
  440.  
  441.             # use -o only if directed to do so
  442.                     ccall="$stopflag $ccargs"
  443.             if [ $useoflag = y ]; then ccall="$ccall -o $ofile"; fi
  444.  
  445.                     if $thecc $ccall $tmpi; then
  446.             objfiles="$objfiles $ofile"
  447.                     else
  448.                         exits 1 $junk; # cc failed
  449.                     fi
  450.                  fi
  451.               else # objc1 failed
  452.                  exits 1 $junk;
  453.               fi
  454.         else # cpp failed
  455.         exits 1 $junk; # cpp failed
  456.         fi
  457.     else # -E case
  458.       if [ $comments = y ]; then
  459.        $thecpp -C $ccargs $cpargs $tmpc
  460.       else
  461.        $thecpp $ccargs $cpargs $tmpc
  462.       fi
  463.     fi
  464.  
  465.     rmf $junk
  466.       ;;
  467.       c|cc) if [ $compile = y ]; then
  468.  
  469.         ccall="$stopflag $cpargs $ccargs"
  470.         # use -o only if directed to do so
  471.         if [ $useoflag = y ]; then ccall="$ccall -o $ofile"; fi
  472.  
  473.             if $thecc $ccall $input; then
  474.                 objfiles="$objfiles $ofile"
  475.             else
  476.                  exits 1 ""; # cc failed
  477.             fi
  478.         fi
  479.       ;;
  480.       o|a)
  481.     objfiles="$objfiles $input"
  482.       ;;
  483.     esac
  484.  
  485.  done
  486.  
  487. #
  488. # Select libraries and link
  489. #
  490.  
  491. if [ $link = y -a $linkdl = n ]; then
  492.  
  493.     if [ $uselibs = y ]; then
  494.     for G in $cakit $objpak $objcrt
  495.     do
  496.         L="${libdir}/${G}"
  497.         H="${libdir}/lib${G}${sosuffix}"
  498.         if [ $profile = y -a -f ${L}_p.a ]; then
  499.            libs="$libs ${L}_p.a";continue;
  500.         fi
  501.  
  502.         if [ $debug = y -a -f ${L}_g.a ]; then
  503.            libs="$libs ${L}_g.a";continue;
  504.         fi
  505.  
  506.         if [ $dynamic = y -a -f $H ]; then
  507.            case $uselflag in
  508.             1) libs="$libs -L${libdir} -l${G}";;
  509.             0) libs="$libs ${H}";;
  510.            esac
  511.            continue
  512.         fi
  513.         
  514.             if [ -f $L.a ]; then
  515.            # do not add if absent (e.g. cakit)
  516.                libs="$libs $L.a";
  517.         else
  518.            echo "objc: warning: can't find" $L.a
  519.         fi
  520.     done
  521.     fi
  522.  
  523.     if [ $runxstr = y ]; then
  524.     $xstr -s $xstrdb # assemble strings collected in file "strings"
  525.     $cc $stopflag $ccargs xs.c
  526.     objfiles="$objfiles xs.o"
  527.     fi
  528.  
  529.     # add things that have to be added at the end
  530.     libs="$libs $finlibs"
  531.  
  532.     if [ $postlink = 0 ]; then
  533.  
  534.         if $thecc $ldargs $objfiles $libs -o $output; then
  535.       if [ $retain = n ]; then junk="postlink.map"; fi
  536.     else
  537.       exits 1 $junk
  538.     fi
  539.  
  540.         case $linkformat in
  541.            unix|bsdnm) $nm $output > postlink.map ;;
  542.        metrowerks) ;;
  543.     esac
  544.  
  545.     # do a test here to verify that no modules were compiled
  546.     # with -postlink
  547.     
  548.     if grep OBJCPOSTLINK postlink.map; then
  549.         echo "Warning: use -postlink to link files compiled with -postlink."
  550.     fi
  551.  
  552.     if [ $retain = n ]; then rmf $junk;fi
  553.  
  554.     else
  555.        # postlink is a compile-time alternative to auto-initialization
  556.        # of the objc system ( auto-initialization does the work at "runtime" )
  557.  
  558.     junk="_postlnk.o"
  559.     if [ $retain = n ]; then junk="$junk _postlnk.c"; fi
  560.  
  561.     # the executable that is produced in this first link will not 
  562.     # work so add it to junk (it is only for getting a postlink.map)
  563.     
  564.     trap 'exits 1 $output $junk' 1 2 3 10 15
  565.  
  566.     if [ -f $libdir/_prelink.o ]; then
  567.      if $thecc $ldargs $objfiles $libdir/_prelink.o $libs -o $output; then
  568.        if [ $retain = n ]; then junk="$junk postlink.map"; fi
  569.      else
  570.        exits 1 $junk
  571.      fi
  572.     else
  573.          echo "Can't find file $libdir/_prelink.o.";rmf $junk;exit 1;
  574.     fi
  575.  
  576.         case $linkformat in
  577.            unix|bsdnm) $nm $output > postlink.map ;;
  578.        metrowerks) ;;
  579.     esac
  580.  
  581.     $bindir/postlink - postlink.map _postlnk.c
  582.     rmf $output
  583.  
  584.         # link second time, using postlnk.o file
  585.     
  586.         $cc $stopflag $ccargs _postlnk.c
  587.     $thecc $ldargs $objfiles _postlnk.o $libs -o $output
  588.         rmf $junk
  589.     fi
  590. fi
  591.  
  592. # building dynamic libraries 
  593.  
  594. if [ $link = y -a $linkdl = y ]; then
  595.  
  596.     if [ ! -f $dlfile ]; then dlfile="$objcdir/lib32/$dlfile"; fi;
  597.     if [ ! -f $dlfile ]; then echo "objc: Can't find" $dlfile; exit 1; fi
  598.  
  599.     junk="_postlnk.o"
  600.     if [ $retain = n ]; then junk="$junk postlink.map _postlnk.c"; fi
  601.     $ld -r $ldargs $objfiles $libs -o $output 
  602.  
  603.     case $linkformat in
  604.        unix|bsdnm) $nm $output >postlink.map ;;
  605.        metrowerks) ;;
  606.     esac
  607.  
  608.     $bindir/postlink -a $dlfile - postlink.map _postlnk.c
  609.  
  610.     rmf $output
  611.     $cc $stopflag $picflag $ccargs _postlnk.c
  612.     $ld $dlargs $ldargs $objfiles _postlnk.o $libs -o $output
  613.     rmf $junk
  614. fi 
  615.  
  616.